<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_LOCALES_COLLECTION_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="MAIL_TEMPLATE_AVAIALABLE_VARIABLES_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.common.Constants" var="MIME_TYPE_PLAIN" />
<atleap:constants className="com.blandware.atleap.common.Constants" var="MIME_TYPE_HTML" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="HTML_TEXT_FIELD_MAX_LENGTH" />
<atleap:content identifier="information" ignore="true" uri="/core/mailTemplate/callUpdate"/>
<atleap:messages property="updateFailed" />
<atleap:messages property="notSupportedCharset" />
<atleap:form action="core/mailTemplate/callUpdateBody" method="POST" validateOnSubmit="false">
	<div>
		<c:if test="${!empty sessionScope[pageScope.MAIL_TEMPLATE_AVAIALABLE_VARIABLES_KEY]}">
			<atleap:message key="core.mailTemplate.form.availableVariables" arg0="${sessionScope[pageScope.MAIL_TEMPLATE_AVAIALABLE_VARIABLES_KEY]}" /><br />
		</c:if>
	</div>
    <table cellpadding="0" cellspacing="0" border="0" class="modificationTable">
		<tr>
			<td colspan="2" align="center">
				<atleap:label property="from" key="core.mailTemplate.form.from" colon="false" helpTip="true" />
			</td>
		</tr>
		<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
			<tr>
				<th>
					<div class="languageField">
						<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
						<c:if test="${empty languageTitle}">
							<c:set var="languageTitle" value="${contentLocale.identifier}" />
						</c:if>
						<atleap:message key="core.mailTemplate.form.language" />:&nbsp;${languageTitle}
					</div>
				</th>
				<td>
					<html:text property="from(${contentLocale.identifier})"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
				</td>
			</tr>
		</atleap:iterator>
		<tr>
			<td colspan="2" align="center">
				<atleap:label property="subject" key="core.mailTemplate.form.subject" colon="false" helpTip="true" />
			</td>
		</tr>
		<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
			<tr>
				<th>
					<div class="languageField">
						<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
						<c:if test="${empty languageTitle}">
							<c:set var="languageTitle" value="${contentLocale.identifier}" />
						</c:if>
						<atleap:message key="core.mailTemplate.form.language" />:&nbsp;${languageTitle}
					</div>
				</th>
				<td>
					<html:text property="subject(${contentLocale.identifier})"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
				</td>
			</tr>
		</atleap:iterator>
		<tr>
			<td colspan="2" align="center">
				<atleap:label property="charset" key="core.mailTemplate.form.charset" colon="false" helpTip="true" />
			</td>
		</tr>
		<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
			<tr>
				<th>
					<div class="languageField">
						<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
						<c:if test="${empty languageTitle}">
							<c:set var="languageTitle" value="${contentLocale.identifier}" />
						</c:if>
						<atleap:message key="core.mailTemplate.form.language" />:&nbsp;${languageTitle}
					</div>
				</th>
				<td>
					<html:text property="charset(${contentLocale.identifier})"  maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" styleClass="text" />
					<!-- save body -->
					<html:hidden property="body(${contentLocale.identifier})" />
				</td>
			</tr>
		</atleap:iterator>
		<tr>
			<td colspan="2"></td> 
		</tr>
		<tr>
			<th>
				<atleap:message key="core.mailTemplate.form.mimeType" />
			</th>
			<td>
				<html:select property="mimeType">
					<html:option value="${pageScope.MIME_TYPE_PLAIN}"><atleap:message key="core.mailTemplate.form.mimeType.plain" /></html:option>
					<html:option value="${pageScope.MIME_TYPE_HTML}"><atleap:message key="core.mailTemplate.form.mimeType.html" /></html:option>
				</html:select>
			</td>
		</tr>
	</table>
    <html:hidden property="id" />
    <html:hidden property="version" />
    <atleap:cancel styleClass="button"><atleap:message key="core.commons.buttons.cancel" /></atleap:cancel>
    <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.next" /></atleap:submit>
</atleap:form>
